package com.knowvoyage.knowvoyageserver.controller;

import com.knowvoyage.knowvoyageserver.pojo.vo.QuestionPageVO;
import com.knowvoyage.knowvoyageserver.pojo.vo.Result;
import com.knowvoyage.knowvoyageserver.service.QuestionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "刷题类", description = "获取真题相关接口")
@Slf4j
@RestController
@RequestMapping("/question")
@RequiredArgsConstructor
public class QuestionController {

    private final QuestionService questionService;

    // 组合条件筛选
    @Operation(summary = "根据组合条件查询真题", description = "根据提供的科目（1-数据结构 2-操作系统 3-计算机网络 4-计算机组成原理）、年份、题型（1-选择，2-填空，填空暂无题目）分页查询题目接口，科目年份题型参数均不必须")
    @GetMapping("/filter")
    public Result<QuestionPageVO> getQuestionsByCondition(
            @RequestParam(required = false) Integer type,
            @RequestParam(required = false) Integer subject,
            @RequestParam(required = false) Integer year,
            @RequestParam(defaultValue = "1") int pageNum,
            @RequestParam(defaultValue = "10") int pageSize
    ) {
        QuestionPageVO pageVO = questionService.getQuestionsByCondition(type, subject, year, pageNum, pageSize);
        return Result.success(pageVO);
    }

}
